
<%--
 *  File:    PlanTypeManagement.jsp
 *  @Author: shigang
 *  Date:    2013/05/31
 *
 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%
  //init param
  String strTableName = "v_plantype";
  String strModuleName = "DMS";
  String privilegeCode = "FP0101";
  String contextPath = request.getContextPath(); 

%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>PlanTypeManagement</title>
<PageFlow:CheckPageFlow pageName="p_plantypesummary"/>
<%
	String isNew = "";
	String isDefault = "";
	String paraIsDefault = "";
	//System.out.println("Trace \"isdefault\" ------- summary" + ((String)pageContext.getAttribute("isdefault")));
	if("Y".equals(((String)pageContext.getAttribute("isdefault")))||"Y".equals(request.getParameter("isdefault"))) {
		isDefault = "&isdefault=Y";
		paraIsDefault="Y";
	}else if("N".equals(((String)pageContext.getAttribute("isdefault")))||"Y".equals(request.getParameter("isdefault"))) {
		isDefault = "&isdefault=N";
		paraIsDefault="N";
	}
%>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>
<script language="JavaScript" src="../../js/SummaryDivision.js"></script>



<%
HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
Integer employeeid=(Integer)CurUserInfo.get("userid");
String  isadmin=(String)CurUserInfo.get("isadmin");
if(isadmin==null) isadmin="";
%>
<script language="JavaScript">


function clickRow(id,status)
{
  document.frm.plantypeid.value = id;

  document.frm.status.value = status;
}
function page_new()
{
	<%isNew = "&isNew=Y";%>
   location.href="PlanTypeFrm.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%><%=JspHelper.filterNull(isNew)%>";
}
function page_delete()
{	
	if(isEmpty(document.frm.plantypeid.value) || document.frm.plantypeid.value == -1)
	{
		return;
	}
	
	if(document.frm.status.value !=10)
	{
	   alert("<%= message.getMessageDesc("CAN_NOT_DELETE_BY_STATUS10") %>");
		return;
	}
	
    var frm = document.frm;
	if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE") %>") )
		  return;

	
	frm.actionname.value="delete";
	frm.target = "_self";
    isRunning = true;
    frm.submit();
}


function page_submit()
{	
	if(isEmpty(document.frm.plantypeid.value) || document.frm.plantypeid.value == -1)
	{
		return;
	}
    var frm = document.frm;
    
    
   if(document.frm.status.value !=10)
	{
	   alert("<%= message.getMessageDesc("CAN_NOT_SUBMIT_BY_STATUS10") %>");
		return;
	}
	
	if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE") %>") )
		  return;

	

	frm.actionname.value="submit";
	frm.target = "_self";
    isRunning = true;
    frm.submit();
}
function page_edit()
{
	
  var id = document.frm.plantypeid.value;
  
  var editurl;

  if(id == null || id.length == 0 || id == "" || id == "-1")
  {
    alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
    return;
  }  

   if(document.frm.status.value !=10)
	{
	   alert("<%= message.getMessageDesc("CAN_NOT_MODIFY_BY_STATUS10") %>");
		return;
	}

	<%isNew = "&isNew=N";%>
    
	editurl = "PlanTypeFrm.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%>&plantypeid=" + id + "&languagecode=" + "<%= strLanguageCode %><%=JspHelper.filterNull(isNew)%>";
	
    self.location.href = editurl;
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(frm,actionvalue,orderbyname);
  editform.action = "PlanTypeManagement.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%>&languagecode=<%= strLanguageCode %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}


</script>
</head>
<body>

<form name="frm" method="post" action="<%=contextPath %>/Dispatcher">
<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
   
      <input type="hidden" name="pagename" value="p_plantypesummary">
      <input type="hidden" name="currentnum">
      <input type="hidden" name="actionname">   
      <input type="hidden" name="isdefault" value="<%= paraIsDefault %>">   
  <tr> 
    <td> 
      <table width="100%" border="0" cellspacing="0">
        <tr> 
          <td class="summary_top" colspan="3" ></td>
        </tr>
        <tr>
          <td>    
	 <table border="0" cellspacing="0">    
            <%--@ include file="/inc/SummarySearch.inc" --%>  
            
      <tr> 
    	<td valign="top"> 
    		<table border="0" cellspacing="0">  
    		  
            	<%@ include file="/inc/SummarySearch.inc" %>  
            	
            </table>
        </td>
   	</tr>
  </table>
            
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td> 
      <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">
          <tr class="deepblue-left">
			<td  class="title_center">&nbsp;</td>
            <td  class="title_center"><%= label.getLabelName("L_TypeCode")%></td>
            <td  class="title_center"><%= label.getLabelName("L_TypeName")%></td>
            <td  class="title_center"><%= label.getLabelName("L_Use")%></td>
            <td  class="title_center"><%= label.getLabelName("L_TypeDescription ")%></td>
            <td  class="title_center"><%= label.getLabelName("L_Status")%></td>
		</tr>

          <%
             Vector plantypesummary1 = (Vector)pageContext.getAttribute("plantypesummary");
             if(plantypesummary1 == null)
             {
            	 plantypesummary1 = new Vector();
             }
             
             System.out.println(plantypesummary1.size());
             String strClassType = new String("");   
             Integer nDefaultId = null;             
             Integer nDefaultStatus = null;
             Integer nDefaultVersion = new Integer(-1);
             int i=0;
             String strChecked = "";
             boolean bHasChecked = false;
          %>   
          <logic:iterate id="plantypesummary" collection="<%= plantypesummary1 %>">
          <%
            if(i%2 == 1)
            {
              strClassType = "td-listrom";
            }else{                    
              strClassType = "none";
            }
            if(!bHasChecked)
            {
              nDefaultId = (Integer)((HashMap)pageContext.getAttribute("plantypesummary")).get("plantypeid");
             nDefaultStatus = (Integer)((HashMap)pageContext.getAttribute("plantypesummary")).get("status");
            //  System.out.println("--nDefaultId--" + nDefaultId);
              
              bHasChecked = true;
              strChecked = "Checked";
            }
            else
            {
              strChecked = "";
            }
            i++;
          %>            
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="radiotrue('plantypeid<%=JspHelper.filterNull( i )%>');
			    javascript:clickRow('<oval:write name="plantypesummary" property="plantypeid" />',
			                        '<oval:write name="plantypesummary" property="status" />');"
          class="<%=JspHelper.filterNull( strClassType )%>"> 
            <td> 
              <input <%=JspHelper.filterNull( strChecked )%> id="plantypeid<%=JspHelper.filterNull( i )%>" type="radio" name="order" value="<oval:write name="plantypesummary" property="plantypeid"/>" class="normalradio"/>
            </td>       
            <td class="hand"><a href="PlanTypeFrm.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%>&viewflag=view&plantypeid=<custom:write name="plantypesummary" property="plantypeid"/>"><custom:write name="plantypesummary" property="plantypecode" nbsp="true"/></a></td>
           <td><custom:write name="plantypesummary" property="plantypename" nbsp="true"/></td>
            <td><custom:write name="plantypesummary" property="planpurposename" nbsp="true"/></td>
            <td><custom:write name="plantypesummary" property="comments" nbsp="true"/></td>
            <td><custom:write name="plantypesummary" property="statusname" nbsp="true"/></td>



			
          </tr>
          </logic:iterate> 
        <%
            String history=(String)pageContext.getAttribute("history");
        %> 
        <input type="hidden" name="plantypeid" value="<%=JspHelper.filterNull( nDefaultId )%>">
         <input type="hidden" name="status" value="<%=JspHelper.filterNull( nDefaultStatus )%>">
        
        <%@ include file="/inc/SummaryAction.inc" %>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top" ></td>
        </tr>
        <tr>
        
          <td class="td_center">

              <a onclick="page_new()"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>

              <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
              
              <a onclick="page_submit()"><custom:button type="1" label="L_Submit" imgsrc="edit.gif" border="0" style="width:60"/></a>
              
              <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>


          </td>
        </tr>
      </table>
    </td>
  </tr>

</table>
 </form>
</body>
</html>
